﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Htse.Blue.Controllers
{
	[HandleError]
	public class HomeController : Controller
	{
		public ActionResult Index()
		{
			ViewData["Message"] = "Benvenuti in Blue! Work in progress";

			return View();
		}

		public ActionResult About()
		{
			return View();
		}

		[Authorize]
		public RedirectToRouteResult ChangePageSize(int pageSize, string redirectToController, string redirectToAction)
		{
			SiteConstants.SetPreferredPageSize(Session, pageSize);

			return RedirectToRoute(new { Controller = redirectToController, Action = redirectToAction });
		}

		[Authorize]
		public JsonResult GetAvailablePageSizes()
		{
			IDictionary<string, string> values = new Dictionary<string, string>()
			{
				{"5", "5"},
				{"10", "10"},
				{"20", "20"},
			};

			var result = from item in values
							 select new { Text = item.Value, Value = item.Key };

			return Json(result, JsonRequestBehavior.AllowGet);
		}
	}
}
